{# Copyright The IETF Trust 2015-2023, All Rights Reserved #}
{% load origin %}
{% origin %}
{% load ietf_filters %}
<li class="nav-item dropdown">
    {% if flavor == "top" %}
        <a href="#"
           class="nav-link dropdown-toggle"
           role="button"
           data-bs-toggle="dropdown"
           aria-expanded="false">
            {% if user.is_authenticated %}
                {{ user.username|split:'@'|first }}
            {% else %}
                User
            {% endif %}
        </a>
        <ul class="dropdown-menu {% if flavor == 'top' %} mt-n1 {% else %} ms-n1 {% endif %}">
        {% else %}
            <span class="fw-bolder">User</span>
        </li>
    {% endif %}
    {% url 'django.contrib.auth.views.logout' as logout_url %}
    {% if request.get_full_path == logout_url %}
        <li>
            <a class="dropdown-item {% if flavor != 'top' %} text-wrap{% endif %}"
               rel="nofollow"
               href="{% url 'ietf.ietfauth.views.login' %}">
                Sign in
            </a>
        </li>
    {% else %}
        {% if user.is_authenticated %}
            <li>
                <form id="logout-form" method="post" action="{% url 'django.contrib.auth.views.logout' %}">
                    {% csrf_token %}
                    <button class="dropdown-item {% if flavor != 'top' %} text-wrap{% endif %}" 
                            type="submit">
                        Sign out
                    </button>
                </form>
            </li>
            <li>
                <a class="dropdown-item {% if flavor != 'top' %} text-wrap{% endif %}"
                   rel="nofollow"
                   href="{% url 'ietf.ietfauth.views.profile' %}">
                    Account info
                </a>
            </li>
            {% if user and user.person %}
                <li>
                    <a class="dropdown-item {% if flavor != 'top' %} text-wrap{% endif %}"
                       href="{% url 'ietf.person.views.profile' email_or_name=user.person.name %}">
                        Public profile page
                    </a>
                </li>
            {% endif %}
            <li>
                <a class="dropdown-item {% if flavor != 'top' %} text-wrap{% endif %}"
                   href="{% url 'ietf.cookies.views.preferences' %}"
                   rel="nofollow">
                    Preferences
                </a>
            </li>
            <li>
                <a class="dropdown-item {% if flavor != 'top' %} text-wrap{% endif %}"
                   href="{% url 'ietf.ietfauth.views.apikey_index' %}"
                   rel="nofollow">
                    API keys
                </a>
            </li>
            <li>
                <a class="dropdown-item {% if flavor != 'top' %} text-wrap{% endif %}"
                   rel="nofollow"
                   href="{% url 'ietf.ietfauth.views.change_password' %}">
                    Change password
                </a>
            </li>
            <li>
                <a class="dropdown-item {% if flavor != 'top' %} text-wrap{% endif %}"
                   rel="nofollow"
                   href="{% url 'ietf.ietfauth.views.change_username' %}">
                    Change username
                </a>
            </li>
        {% else %}
            <li>
                <a class="dropdown-item {% if flavor != 'top' %} text-wrap{% endif %}"
                   rel="nofollow"
                   href="{% url 'ietf.ietfauth.views.login' %}?next={{ request.get_full_path|removeprefix:'/accounts/login/?next='|urlencode }}">
                    Sign in
                </a>
            </li>
            <li>
                <a class="dropdown-item {% if flavor != 'top' %} text-wrap{% endif %}"
                   rel="nofollow"
                   href="{% url 'ietf.ietfauth.views.password_reset' %}">
                    Password reset
                </a>
            </li>
            <li>
                <a class="dropdown-item {% if flavor != 'top' %} text-wrap{% endif %}"
                   href="{% url 'ietf.cookies.views.preferences' %}"
                   rel="nofollow">
                    Preferences
                </a>
            </li>
        {% endif %}
    {% endif %}
    {% if not request.user.is_authenticated %}
        <li>
            <a class="dropdown-item {% if flavor != 'top' %} text-wrap{% endif %}"
               href="{% url 'ietf.ietfauth.views.create_account' %}">
                New account
            </a>
        </li>
    {% endif %}
    <li class="dropend">
      <a class="dropdown-item dropdown-toggle" href="#">
        List subscriptions
      </a>
      <ul class="dropdown-menu">
            <li>
                <a class="dropdown-item {% if flavor != 'top' %}text-wrap{% endif %}"
                href="https://mailman3.ietf.org/mailman3/lists/">
                    IETF Lists
                </a>
            </li>
            <li>
                <a class="dropdown-item {% if flavor != 'top' %}text-wrap{% endif %}"
                href="https://mailman3.irtf.org/mailman3/lists/">
                IRTF Lists
                </a>
            </li>
            <li>
                <a class="dropdown-item {% if flavor != 'top' %}text-wrap{% endif %}"
                href="https://mailman3.iab.org/mailman3/lists/">
                    IAB Lists
                </a>
            </li>
            <li>
                <a class="dropdown-item {% if flavor != 'top' %}text-wrap{% endif %}"
                href="https://mailman3.rfc-editor.org/mailman3/lists/">
                    RFC-Editor Lists
                </a>
            </li>
        </ul>
    </li>
    {% if user|has_role:"Reviewer" %}
        <li>
            <a class="dropdown-item {% if flavor != 'top' %} text-wrap{% endif %}"
               href="{% url 'ietf.ietfauth.views.review_overview' %}">
                My reviews
            </a>
        </li>
    {% endif %}
    {% if user|has_role:"Area Director" %}
        {% if flavor == "top" %}<li><hr class="dropdown-divider"></li>{% endif %}
        <li {% if flavor == "top" %}class="dropdown-header"{% else %}class="nav-item fw-bolder"{% endif %}>AD dashboard</li>
        <li>
            <a class="dropdown-item {% if flavor != 'top' %} text-wrap{% endif %}"
               href="{% url 'ietf.doc.views_search.docs_for_ad' name=user.person.full_name_as_key %}">
                My docs
            </a>
        </li>
        <li>
            <a class="dropdown-item {% if flavor != 'top' %} text-wrap{% endif %}"
               href="{% url 'ietf.iesg.views.agenda_documents' %}">
                Next telechat
            </a>
        </li>
        <li>
            <a class="dropdown-item {% if flavor != 'top' %} text-wrap{% endif %}"
               href="{% url 'ietf.iesg.views.discusses' %}">
                Discusses
            </a>
        </li>
        <li>
            <a class="dropdown-item {% if flavor != 'top' %} text-wrap{% endif %}"
               href="{% url 'ietf.iesg.views.milestones_needing_review' %}">
                Milestone review
            </a>
        </li>
        <li>
            <a class="dropdown-item {% if flavor != 'top' %} text-wrap{% endif %}"
               href="{% url 'ietf.doc.views_search.drafts_in_last_call' %}">
                Last Call docs
            </a>
        </li>
    {% endif %}
    {% if user|has_role:"Secretariat" %}
        {% if flavor == "top" %}<li><hr class="dropdown-divider"></li>{% endif %}
        <li {% if flavor == "top" %}class="dropdown-header"{% else %}class="nav-item fw-bolder"{% endif %}>
            IETF secretariat
        </li>
        <li>
            <a class="dropdown-item {% if flavor != 'top' %} text-wrap{% endif %}"
               href="{% url 'admin:iesg_telechatdate_changelist' %}">
                Telechat dates
            </a>
        </li>
        <li>
            <a class="dropdown-item {% if flavor != 'top' %} text-wrap{% endif %}"
               href="{% url 'admin:iesg_telechatagendaitem_changelist' %}">
                Management items
            </a>
        </li>
        <li>
            <a class="dropdown-item {% if flavor != 'top' %} text-wrap{% endif %}"
               href="{% url 'ietf.iesg.views.milestones_needing_review' %}">
                Milestones
            </a>
        </li>
        <li>
            <a class="dropdown-item {% if flavor != 'top' %} text-wrap{% endif %}"
               href="{% url 'ietf.sync.views.discrepancies' %}">
                Sync discrepancies
            </a>
        </li>
    {% endif %}
    {% if user|has_role:"IANA" %}
        {% if flavor == "top" %}
            <li><hr class="dropdown-divider">
            </li>
        {% endif %}
        <li {% if flavor == "top" %}class="dropdown-header"{% else %}class="nav-item fw-bolder"{% endif %}>
            IANA
        </li>
        <li>
            <a class="dropdown-item {% if flavor != 'top' %} text-wrap{% endif %}"
               href="{% url 'ietf.sync.views.discrepancies' %}">
                Sync discrepancies
            </a>
        </li>
    {% endif %}
    {% if user|has_role:"RFC Editor" %}
        {% if flavor == "top" %}
            <li><hr class="dropdown-divider">
            </li>
        {% endif %}
        <li {% if flavor == "top" %}class="dropdown-header"{% else %}class="nav-item fw-bolder"{% endif %}>
            RFC Editor
        </li>
        <li>
            <a class="dropdown-item {% if flavor != 'top' %} text-wrap{% endif %}"
               href="{% url 'ietf.sync.views.discrepancies' %}">
                Sync discrepancies
            </a>
        </li>
    {% endif %}
    {% if flavor == "top" %}</ul></li>{% endif %}